var condition="null";
var fuzerenId="all";
var state="all";
jQuery(document).ready(function() {
//	$('#kit-search-more').on('click', function() {
//		$('.kit-search-mored').toggle();
//	});
	bindFuzerenSelect2(); // 2018-9-18 chenbin: 新增，绑定负责人下拉框
	bindStateSelect2();
	
	var col = [ 
		{
			title:'预约ID',
			field:'orderId',
			align: 'center',
			valign: 'middle',
			visible: false
		},
		{
			title:'申请日期',
			field:'applyTime',
			align: 'center',
			valign: 'middle',
			formatter: function (value, row, index) {			
				var date = new Date(row.applyTime);
				Y = date.getFullYear() + '-';
				M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
				D = date.getDate() + ' ';
				var result = Y+M+D; 
				return result;
			}
		},
		{
			title:'英文名',
			field:'enName',
			align: 'center',
			valign: 'middle'
		},
		{
			title:'性别',
			field:'sex',
			align: 'center',
			valign: 'middle',
			visible: false
		},
		{
			title:'年龄',
			field:'age',
			align: 'center',
			valign: 'middle'
		},
		{
			title:'QQ号',
			field:'qq',
			align: 'center',
			valign: 'middle',
			visible: false
		},
		{
			title:'邮箱',
			field:'email',
			align: 'center',
			valign: 'middle',
			visible: false
		},
		{
			title:'电话',
			field:'phone',
			align: 'center',
			valign: 'middle'
		},
		{
			title:'状态',
			field:'state',
			align: 'center',
			valign: 'middle'
		},
		{
			title:'外教',
			field:'teacherName',
			align: 'center',
			valign: 'middle'
		},
		{
			title:'负责人',
			field:'fuzerenName',
			align: 'center',
			valign: 'middle'
		},
		{
			title:'推荐人',
			field:'recommendName',
			align: 'center',
			valign: 'middle',
			formatter: function (value, row, index) {
				if(row.recommendId !=null){
                    return row.recommendName;
				}else {
                    return '-';
                }
            }
		},
        {
            title:'提交状态',
            field:'submitStatus',
            align: 'center',
            valign: 'middle'
        },
		{
			title:'课程名称',
			field:'lessonName',
			align: 'center',
			valign: 'middle',
			visible: false
		},
		{
			title:'来源',
			field:'source',
			align: 'center',
			valign: 'middle',
			visible: false
		},
		{
			title:'备注',
			field:'remark',
			align: 'center',
			valign: 'middle'
		},
		{
			title: '管理',
		    // formatter: function (value, row, index) {
		    // 	console.log('row', row);
		    // 	if (row.state == '完成') {
		    // 		if (row.istrylisten == '否') {
			 //    		return '<a href="javascript:;" onclick="Allot(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">分配</a>'+
				// 	    '<a href="javascript:;" onclick="Edit(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">编辑</a>'+
				// 	    '<a href="javascript:;" onclick="Remark(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">备注</a>'+
				// 	    '<a href="javascript:;" onclick="State(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">状态</a>'+
				// 	    '<a href="javascript:;" onclick="InsertAudition(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">提交信息</a>'+
				// 		'<a href="javascript:;" onclick="Delete(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn-danger">删除</a>';
			 //    	}
			 //    	else {
			 //    		return '<a href="javascript:;" onclick="Allot(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">分配</a>'+
				// 	    '<a href="javascript:;" onclick="Edit(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">编辑</a>'+
				// 	    '<a href="javascript:;" onclick="Remark(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">备注</a>'+
				// 	    '<a href="javascript:;" onclick="State(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">状态</a>'+
				// 	    '<a href="javascript:;" onclick="UpdateAudition(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">更新信息</a>'+
				// 		'<a href="javascript:;" onclick="Delete(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn-danger">删除</a>';
			 //    	}
		    // 	}
		    // 	else {
		    // 		return '<a href="javascript:;" onclick="Allot(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">分配</a>'+
				//     '<a href="javascript:;" onclick="Edit(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">编辑</a>'+
				//     '<a href="javascript:;" onclick="Remark(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">备注</a>'+
				//     '<a href="javascript:;" onclick="State(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">状态</a>'+
				// 	'<a href="javascript:;" onclick="Delete(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn-danger">删除</a>';
		    // 	}
		    // } //自定义方法，添加操作按钮
            formatter: function (value, row, index) {
                console.log('row', row);
                if(row.state == '完成' ){
                	if(row.submitStatus == '未提交'){
                        return '<a href="javascript:;" onclick="Allot(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">分配</a>'+
                            '<a href="javascript:;" onclick="Edit(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">编辑</a>'+
                            '<a href="javascript:;" onclick="Remark(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">备注</a>'+
                            '<a href="javascript:;" onclick="State(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">状态</a>'+
                            '<a href="javascript:;" onclick="InsertAudition(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">&nbsp;提 交&nbsp;</a>'+
                            '<a href="/MeiSiEnglish/freeAuditions/download/'+row.orderId+'"  class="layui-btn layui-btn-sm layui-btn">下载</a>'+
                        '<a href="javascript:;" onclick="Delete(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn-danger">删除</a>';
                            // '<a href="javascript:;" onclick="Download(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn-danger">下载记录</a>';

                    }else {
                        return '<a href="javascript:;" onclick="Allot(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">分配</a>'+
                            '<a href="javascript:;" onclick="Edit(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">编辑</a>'+
                            '<a href="javascript:;" onclick="Remark(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">备注</a>'+
                            '<a href="javascript:;" onclick="State(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">状态</a>'+
                        '<a href="javascript:return false;" onclick="return false;" style="background-color:#999" class="layui-btn layui-btn-sm layui-btn">已提交</a>'+
                            '<a href="/MeiSiEnglish/freeAuditions/download/'+row.orderId+'"  class="layui-btn layui-btn-sm layui-btn">下载</a>'+
                            '<a href="javascript:;" onclick="Delete(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn-danger">删除</a>';
                        	// '<a href="javascript:;" onclick="Download(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn-danger">下载记录</a>';

                    }

                } else {
                    return '<a href="javascript:;" onclick="Allot(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">分配</a>'+
                                    '<a href="javascript:;" onclick="Edit(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">编辑</a>'+
                                    '<a href="javascript:;" onclick="Remark(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">备注</a>'+
                                    '<a href="javascript:;" onclick="State(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn">状态</a>'+
                                    '<a href="javascript:return false;" onclick="return false;" style="background-color:#999" class="layui-btn layui-btn-sm layui-btn">未提交</a>'+
                        '<a href="/MeiSiEnglish/freeAuditions/download/'+row.orderId+'" style="background-color:#999" class="layui-btn layui-btn-sm layui-btn">下载</a>'+
                        '<a href="javascript:;" onclick="Delete(\''+row.orderId+'\')" class="layui-btn layui-btn-sm layui-btn-danger">删除</a>';
                }
            } //自定义方法，添加操作按钮
		}];
	
	//------------------------------------------加载列表
	$('#_table').bootstrapTable({
		url:baseUrl+'/freeAuditions',
		'method': "GET",
		locale: 'zh-CN',
		detailView: false,
		sidePagination: "server", //服务端处理分页
		striped: true,//隔行变色
		undefinedText: "",
		pagination: true,
		singleSelect: false,
		pageSize: pageList[0],
		cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
		pageNumber: 1,
		pageList: pageList,
		search: false, //不显示 搜索框
		uniqueId: "orderId", //每一行的唯一标识，一般为主键列
		showColumns: true, //不显示下拉框（选择显示的列）
		undefinedText: '',
		columns: col,
		showRefresh: true,
		queryParams: function(params) {
			return {
				pageNum: this.pageNumber,
				pageSize: this.pageSize,
				sortOrder: params.order
			}
		},
		
	});
	
	
	// 2018-10-11 chenbin: 下拉框条件查询
    document.getElementById("_fuzerenSelect").onchange = function () {
        fuzerenId = this.value;
        var selectCondition;
        if (fuzerenId == "all" && state == "all") {
            $("#_table").bootstrapTable('refresh', {url: baseUrl + '/freeAuditions'});
        }
        else {
            selectCondition = fuzerenId + "&" + state;
            $("#_table").bootstrapTable('refresh', {url: baseUrl + '/freeAuditions/selectByCondition/' + selectCondition});
        }
    };
    document.getElementById("_stateSelect").onchange = function () {
        state = this.value;
        var selectCondition;
        if (fuzerenId == "all" && state == "all") {
            $("#_table").bootstrapTable('refresh', {url: baseUrl + '/freeAuditions'});
        }
        else {
            selectCondition = fuzerenId + "&" + state;
            $("#_table").bootstrapTable('refresh', {url: baseUrl + '/freeAuditions/selectByCondition/' + selectCondition});
        }
    };
})

// 2018-9-18 chenbin: 新增，绑定负责人下拉框
function bindFuzerenSelect2() {
	var fuzerenData = [];
	$.ajax({
		type : "get",
		url : baseUrl+'/admins/select2',
		async : false,
		success : function(data) {
			fuzerenData = data;
//			fuzerenData.unshift({
//				id : 'all',
//				text : '请选择'
//			});
		}
	});

	$('#_fuzerenSelect').select2({
		data : fuzerenData
	});
}

//状态下拉初始化
function bindStateSelect2() {
	var stateData = [
		{
			id : '1',
			text : '待跟进'
		},
		{
			id : '2',
			text : '跟进中'
		},
		{
			id : '3',
			text : '完成'
		},
		{
			id : '4',
			text : '失联'
		}
	];
	$('#_stateSelect').select2({
		data : stateData
	});
}

//// 2018-9-18 chenbin: 新增，刷新表格
//var refresh = function() {
//	$("#_table").bootstrapTable('refresh');
//}

// 2018-10-13 chenbin: 搜索框条件搜索，支持名字、电话号搜索
function searchByCondition(){
	condition = $('#conditionText').val();
	var pattern = /[0-9]/; // 2018-10-13 chenbin: 判断是否包含数字
	if(condition==""){
		$("#_table").bootstrapTable('refresh',{url : baseUrl+'/freeAuditions'});
	}
	else if (pattern.test(condition)){
		$("#_table").bootstrapTable('refresh',{url : baseUrl+'/freeAuditions/searchByPhone/' + condition});
	}
	else {
		$("#_table").bootstrapTable('refresh',{url : baseUrl+'/freeAuditions/searchByName/' + condition});
	}
}
// 2018-10-13 chenbin: 提交到试听管理和学员中心
function InsertAudition(orderId){
	$.ajax({
		url: baseUrl+'/freeAuditions/InsertToAudition/'+orderId,
		type: 'GET',
		success: function(data) {
			alert(data.msg);
			$('#_table').bootstrapTable('refresh');
		}
	});
}
function UpdateAudition(orderId){
	$.ajax({
		url: baseUrl+'/freeAuditions/UpdateAudition/'+orderId,
		type: 'GET',
		success: function(data) {
			alert(data.msg);
			$('#_table').bootstrapTable('refresh');
		}
	});
}

//分享url 
function Share(){
	parent.layer.open({
		maxmin: true,
		type: 2,
		title: '分享预约地址',
		area: ['300px','300px'],
		content: './views/form/Share.html', 
	});
}
function Edit(orderId) {
	parent.layer.open({
		maxmin: true,
		type: 2,
		area: modalArea,
		content: './views/form/FreeAuditionEdit.html?orderId='+orderId, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
//		content: './views/form/StudentEdit.html?orderId='+orderId, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
		btn: ['保存', '取消'],
		yes: function(index, layero) {
			var data = $(layero).find("iframe")[0].contentWindow.callback_save();
			console.log('// 2018-10-14 chenbin: ',data);
			$.ajax({
				url:baseUrl+'/freeAuditions/'+orderId,
				type: 'POST',
				data: data,
				success: function(data) {
					// alert(data.msg);
					parent.layer.close(index);
					$('#_table').bootstrapTable('refresh');
				}
			});
		},
		btn2: function(index, layero) {
			//按钮【按钮二】的回调
//			alert(index);
			//return false 开启该代码可禁止点击该按钮关闭
		}
	});
}
//分配 
 function Allot(orderId){
	parent.layer.open({
		maxmin: true,
		type: 2,
		title: '分配负责人',
		area: ['300px','310px'],
		content: './views/form/Allot.html?orderId='+orderId, 
		btn: ['保存', '取消'],
//		success: function(layero, index){
//			// 2018-9-25 chenbin: 父页面向子页面传递数据
//			var body = parent.layer.getChildFrame('body',index);//建立父子联系
//			console.log('// 2018-9-25 chenbin: fuzerenId', fuzerenId);
//			body.contents().find('#_fuzerenId').val(fuzerenId);
//		}, 
		yes: function(index, layero) {
			var data = $(layero).find("iframe")[0].contentWindow.callback_save();						
			uid=orderId+"&"+data;
			debugger;
			if(data=="all"){
				alert("请选择负责人");
				parent.layer.close(index);
				$('#_table').bootstrapTable('refresh');
				return;
			}
			$.ajax({
				url: baseUrl+'/freeAuditions/saveAllot/'+uid,
				type: 'GET',
				success: function(data) {
					alert(data.msg);
					parent.layer.close(index);
					$('#_table').bootstrapTable('refresh');
				}
			});
		},
		btn2: function(index, layero) {
		}
	});
} 
 
//备注
 function Remark(orderId){
		parent.layer.open({
			maxmin: true,
			type: 2,
			title: '编辑备注',
			area: ['300px','310px'],
			content: './views/form/Remark.html?orderId='+orderId, 
			btn: ['保存', '取消'],
//			success: function(layero, index){
//				// 2018-9-25 chenbin: 父页面向子页面传递数据
//				var body = parent.layer.getChildFrame('body',index);//建立父子联系
//				body.contents().find('#remark').val(comments);
//			}, 
			yes: function(index, layero) {
				var data = $(layero).find("iframe")[0].contentWindow.callback_save();						
				var postMsg=orderId+"&"+data;
				if(data==""){
					alert("请填写备注后保存");
					parent.layer.close(index);
					$('#_table').bootstrapTable('refresh');
					return;
				}
				$.ajax({
					url: baseUrl+'/freeAuditions/saveRemark/',
					type: 'POST',
					data:{
			            postMsg:postMsg
			        },
					success: function(data) {
						alert(data.msg);
						parent.layer.close(index);
						$('#_table').bootstrapTable('refresh');
					}
				});
			},
			btn2: function(index, layero) {
			}
		});
} 
//状态
 function State(orderId){
		parent.layer.open({
			maxmin: true,
			type: 2,
			title: '编辑状态',
			area: ['300px','350px'],
			content: './views/form/StateEdit.html?orderId='+orderId, 
			btn: ['保存', '取消'],
			yes: function(index, layero) {
				var data = $(layero).find("iframe")[0].contentWindow.callback_save();
				var postMsg=orderId+"&"+data;
//				if(data=="all"){
//					alert("请选择状态!");
//					parent.layer.close(index);
//					$('#_table').bootstrapTable('refresh');
//					return;
//				}
				$.ajax({
					url: baseUrl+'/freeAuditions/saveState/',
					type: 'POST',
					data:{
			            postMsg:postMsg
			        },
					success: function(data) {
						alert(data.msg);
						parent.layer.close(index);
						$('#_table').bootstrapTable('refresh');
					},
					error: function(msg) {
						alert(msg);
					}
				});
			},
			btn2: function(index, layero) {
			}
		});
 }
//删除
 function Delete(orderId){
	 if(window.confirm('确定要删除数据吗？')){ 		 
		 $.ajax({
				url: baseUrl+'/freeAuditions/saveDelete/'+orderId,
				type: 'GET',
				success: function(data) {
					alert(data.msg);
					$('#_table').bootstrapTable('refresh');
				}
			});
		 
		 }
	 else{
		 alert("已取消删除"); 
	} 
 }

function Download(orderId){
        $.ajax({
            url: baseUrl+'/freeAuditions/downloan/'+orderId,
            type: 'GET',
            success: function(data) {
            	if(data.code==1){
                    alert('下载失败！');
                }
            },
            error: function(msg) {
                alert('下载失败！');
            }
        });
}


//var check = function() {
//
//}
//var doDelete = function() {
//	var rows = $('#_table').bootstrapTable('getSelections');
//	if(rows == [] || rows == null || rows.length == 0) {
//		parent.layer.alert('请选择要编辑的数据！', {
//			skin: 'layui-layer-molv', //样式类名
//			closeBtn: 0,
//			anim: 4,
//			time: 2000
//		});
//		return;
//	}
//	if(rows.length != 1) {
//		parent.layer.alert('请选择单条数据进行编辑！', {
//			skin: 'layui-layer-molv', //样式类名
//			closeBtn: 0,
//			anim: 4,
//			time: 1800
//		});
//		return;
//	}
//	$.ajax({
//		type: "delete",
//		url: '/students/' + rows[0].studentId,
//		async: true,
//		success: function(data) {
//			alert(data.msg);
//			$('#_table').bootstrapTable('refresh');
//		}
//	});
//}

//var setaudiotime= function (techerid){
//	parent.layer.open({
//		id:techerid+'info',
//		maxmin: true,
//		type: 2,
//		area: modalArea,
//		content: './views/Period_Used.html?techerid='+techerid,
//		btn: ['保存', '取消'],
//		yes: function(index, layero) {
//			var data = $(layero).find("iframe")[0].contentWindow.callback_save();
//			console.log(layero);
//			$.ajax({
//				url: '/teacherPeriods/save/'+data[0],
//				type: 'POST',
//				data: data[1],//,teacherId:'1245745'
//				dataType:"json",      
//           		contentType:"application/json",
//				success: function(data) {
//					alert(data.data);
////					alert(data.msg);
////					parent.layer.close(index);
////					$('#_table').bootstrapTable('refresh');
//				}
//			});
//		},
//		btn2: function(index, layero) {
//			//按钮【按钮二】的回调
//			console.log(layero);
//			//return false 开启该代码可禁止点击该按钮关闭
//		}
//	});
//}
//
//var insert = function() {
//	parent.layer.open({
//		//				title: false,
//		maxmin: true,
//		type: 2,
//		area: modalArea,
//		content: './views/form/StudentEdit.html',
//		btn: ['保存', '取消'],
//		yes: function(index, layero) {
//			var data = $(layero).find("iframe")[0].contentWindow.callback_save();
//			console.log(layero);
//			$.ajax({
//				url: '/students',
//				type: 'POST',
//				data: data,
//				success: function(data) {
//					alert(data.msg);
//					parent.layer.close(index);
//					$('#_table').bootstrapTable('refresh');
//				}
//			});
//		},
//		btn2: function(index, layero) {
//			//按钮【按钮二】的回调
//			console.log(layero);
//			//return false 开启该代码可禁止点击该按钮关闭
//		}
//	});
//}

//var edit = function() {
//	var rows = $('#_table').bootstrapTable('getSelections');
//	if(rows == [] || rows == null || rows.length == 0) {
//		parent.layer.alert('请选择要编辑的数据！', {
//			skin: 'layui-layer-molv', //样式类名
//			closeBtn: 0,
//			anim: 4,
//			time: 2000
//		});
//		return;
//	}
//	if(rows.length != 1) {
//		parent.layer.alert('请选择单条数据进行编辑！', {
//			skin: 'layui-layer-molv', //样式类名
//			closeBtn: 0,
//			anim: 4,
//			time: 1800
//		});
//		return;
//	}
//	parent.layer.open({
//		//				title: false,
//		maxmin: true,
//		type: 2,
//		area: modalArea,
//		content: './views/form/StudentEdit.html?studentId='+rows[0].studentId, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
//		btn: ['保存', '取消'],
//		yes: function(index, layero) {
//			var data = $(layero).find("iframe")[0].contentWindow.callback_save();
//			//console.log(data);
//			$.ajax({
//				url:'/students/'+rows[0].studentId,
//				type: 'POST',
//				data: data,
//				success: function(data) {
//					alert(data.msg);
//					parent.layer.close(index);
//					$('#_table').bootstrapTable('refresh');
//				}
//			});
//		},
//		btn2: function(index, layero) {
//			//按钮【按钮二】的回调
////			alert(index);
//			//return false 开启该代码可禁止点击该按钮关闭
//		}
//	});
//}
//


//
//
//var fenpei = function(){
////	var rows = $('#_table').bootstrapTable('getSelections');
////	$.ajax({
////		type: "delete",
////		url: '/students/' + rows[0].studentId,
////		async: true,
////		success: function(data) {
////			alert(data.msg);
////			$('#_table').bootstrapTable('refresh');
////		}
////	});
//}


// 2018-10-9 chenbin: 以下是原自动生成的代码
/*jQuery(document).ready(function() {
	$('#kit-search-more').on('click', function() {
		$('.kit-search-mored').toggle();
	});
	
	var col = [ 
	{
	checkbox: 'checkbox'
	},
	{
		title:'id',
		field:'id',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'预约id',
		field:'orderId',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'申请日期',
		field:'applyTime',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'英文名',
		field:'enName',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'性别',
		field:'sex',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'年龄',
		field:'age',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'QQ号',
		field:'qq',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'微信号',
		field:'wechat',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'Zoom ID',
		field:'zoomId',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'邮箱',
		field:'email',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'电话',
		field:'phone',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'住址',
		field:'address',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'英语水平（基础、初级、中级）',
		field:'englishLevel',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'需要加强（听、说、读、写）',
		field:'englishAbility',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'外教id',
		field:'teacherId',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'外教名字',
		field:'teacherName',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'负责人id',
		field:'fuzerenId',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'负责人名字',
		field:'fuzerenName',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'推荐人id',
		field:'recommendId',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'推荐人名字',
		field:'recommendName',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'试听时间',
		field:'auditionTime',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'试听类型（新试听、二次试听）',
		field:'auditionType',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'正式时间',
		field:'formalTime',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'课程id',
		field:'lessonId',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'课程名称',
		field:'lessonName',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'课程等级',
		field:'lessonLevel',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'来源',
		field:'source',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'是否喜欢家庭作业',
		field:'homeworkLike',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'备注',
		field:'remark',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'状态（待跟进、跟进中、完成、失联）',
		field:'state',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'是否更新到试听管理中',
		field:'istrylisten',
		align: 'center',
		valign: 'middle'
	},
	{
		title:'是否删除',
		field:'isdeleted',
		align: 'center',
		valign: 'middle'
	}];

	//------------------------------------------加载列表
	$('#_table').bootstrapTable({
		url:'/freeAuditions',
		'method': "GET",
		locale: 'zh-CN',
		detailView: false,
		sidePagination: "server", //服务端处理分页
		striped: true,//隔行变色
		undefinedText: "",
		pagination: true,
		singleSelect: false,
		pageSize: pageList[0],
		cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
		pageNumber: 1,
		pageList: pageList,
		search: false, //不显示 搜索框
		uniqueId: "orderId", //每一行的唯一标识，一般为主键列
		showColumns: false, //不显示下拉框（选择显示的列）
		undefinedText: '',
		columns: col,
		queryParams: function(params) {
			return {
				pageNum: this.pageNumber,
				pageSize: this.pageSize,
				sortOrder: params.order
			}
		},
		
	});

})
var check = function() {

}
var doDelete = function() {
	var rows = $('#_table').bootstrapTable('getSelections');
	if(rows == [] || rows == null || rows.length == 0) {
		parent.layer.alert('请选择要编辑的数据！', {
			skin: 'layui-layer-molv', //样式类名
			closeBtn: 0,
			anim: 4,
			time: 2000
		});
		return;
	}
	if(rows.length != 1) {
		parent.layer.alert('请选择单条数据进行编辑！', {
			skin: 'layui-layer-molv', //样式类名
			closeBtn: 0,
			anim: 4,
			time: 1800
		});
		return;
	}
	$.ajax({
		type: "delete",
		url: '/freeAuditions/' + rows[0].orderId,
		async: true,
		success: function(data) {
			alert(data.msg);
			$('#_table').bootstrapTable('refresh');
		}
	});
}
var insert = function() {
	parent.layer.open({
		//				title: false,
		maxmin: true,
		type: 2,
		area: modalArea,
		content: './views/form/FreeAuditionEdit.html',
		btn: ['保存', '取消'],
		yes: function(index, layero) {
			var data = $(layero).find("iframe")[0].contentWindow.callback_save();
			console.log(layero);
			$.ajax({
				url: '/freeAuditions',
				type: 'POST',
				data: data,
				success: function(data) {
					alert(data.msg);
					parent.layer.close(index);
					$('#_table').bootstrapTable('refresh');
				}
			});
		},
		btn2: function(index, layero) {
			//按钮【按钮二】的回调
			console.log(layero);
			//return false 开启该代码可禁止点击该按钮关闭
		}
	});
}

var edit = function() {
	var rows = $('#_table').bootstrapTable('getSelections');
	if(rows == [] || rows == null || rows.length == 0) {
		parent.layer.alert('请选择要编辑的数据！', {
			skin: 'layui-layer-molv', //样式类名
			closeBtn: 0,
			anim: 4,
			time: 2000
		});
		return;
	}
	if(rows.length != 1) {
		parent.layer.alert('请选择单条数据进行编辑！', {
			skin: 'layui-layer-molv', //样式类名
			closeBtn: 0,
			anim: 4,
			time: 1800
		});
		return;
	}
	parent.layer.open({
		//				title: false,
		maxmin: true,
		type: 2,
		area: modalArea,
		content: './views/form/FreeAuditionEdit.html?orderId='+rows[0].orderId, //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
		btn: ['保存', '取消'],
		yes: function(index, layero) {
			var data = $(layero).find("iframe")[0].contentWindow.callback_save();
			console.log(layero);
			$.ajax({
				url:'/freeAuditions/'+rows[0].orderId,
				type: 'POST',
				data: data,
				success: function(data) {
					alert(data.msg);
					parent.layer.close(index);
					$('#_table').bootstrapTable('refresh');
				}
			});
		},
		btn2: function(index, layero) {
			//按钮【按钮二】的回调
			alert(index);
			console.log(layero);
			//return false 开启该代码可禁止点击该按钮关闭
		}
	});
}
*/

function AddFreeClass() {
    parent.layer.open({
        maxmin: true,
        type: 2,
        area: ['500px', '373px'],
        content: './views/form/AddFreeClass.html',
        btn: ['保存', '取消'],
        yes: function(index, layero) {
            var data = $(layero).find("iframe")[0].contentWindow.callback_save();
            console.log(layero);
            $.ajax({
                url:baseUrl+ '/freeAuditions',
                type: 'POST',
                data: data,
                success: function(data) {
                    alert(data.msg);
                    parent.layer.close(index);
                    $('#_table').bootstrapTable('refresh');
                }
            });
        },
        btn2: function(index, layero) {
            //按钮【按钮二】的回调
            console.log(layero);
            //return false 开启该代码可禁止点击该按钮关闭
        }
    });
}